using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Acms.SqlDal;

namespace Acms.Bll
{
    public class        UserPostUploadFile : BaseItem
    {
        protected UserPostUploadFile() : base() { }
        protected UserPostUploadFile(Hashtable table) : base(table) { }
        protected UserPostUploadFile(Hashtable table, List<UserPostUploadFile> collection) : base(table, collection) { }

        public static UserPostUploadFile CreateInstance(int userPostUploadId, string key)
        {
            UserPostUploadFile tmp = new UserPostUploadFile();
            tmp.userPostUploadId = userPostUploadId;
            tmp.key = key;
            return tmp;
        }

        private static UserPostUploadFile Get(Hashtable table)
        {
            if (table != null)
            {
                return new UserPostUploadFile(table);
            }
            else
            {
                return null;
            }
        }

        private static List<UserPostUploadFile> Get(Hashtable[] tables)
        {
            if (tables != null)
            {
                List<UserPostUploadFile> tmp = new List<UserPostUploadFile>();
                foreach (Hashtable table in tables)
                {
                    tmp.Add(new UserPostUploadFile(table, tmp));
                }
                return tmp;
            }
            else
            {
                return null;
            }
        }

        protected override Base CreateDal()
        {
            return new UserPostUploadFileDal();
        }

        internal static List<UserPostUploadFile> GetAllByUserPostUploadId(int userPostUploadId)
        {
            UserPostUploadFileDal dal = new UserPostUploadFileDal();
            return Get(dal.GetAllByUserPostUploadId(userPostUploadId));
        }

        internal void Delete()
        {
            base.Delete();
        }

        protected override void DeleteRecord(object concurencyId, Base dal)
        {
            ((UserPostUploadFileDal)dal).Delete(userPostUploadId, key);
        }

        internal void Update()
        {
            base.Update();
        }

        protected override void SaveChanges(ref object concurencyId, Base dal)
        {
            ((UserPostUploadFileDal)dal).Update(userPostUploadId, key, fileId, ref fileType, ref name, ref width, ref height);
        }

        protected override void Load(Hashtable table)
        {
            userPostUploadId = (int)table[UserPostUploadFileDal.Fields.UserPostUploadId];
            key = (string)table[UserPostUploadFileDal.Fields.Key];
            fileId = (int)table[UserPostUploadFileDal.Fields.FileId];
            fileType = (int)table[UserPostUploadFileDal.Fields.FileType];
            name = (string)table[UserPostUploadFileDal.Fields.Name];
            width = (int)table[UserPostUploadFileDal.Fields.Width];
            height = (int)table[UserPostUploadFileDal.Fields.Height];
        }

        private int userPostUploadId;
        public int UserPostUploadId
        {
            get { return userPostUploadId; }
        }

        private string key;
        public string Key
        {
            get { return key; }
        }

        private int fileId;
        public int FileId
        {
            get { return fileId; }
            set { fileId = value; }
        }

        private int fileType;
        public File.FileTypes FileType
        {
            get { return (File.FileTypes)fileType; }
            set { fileType = (int)value; }
        }

        private string name;
        public string Name
        {
            get { return name; }
        }
	

        private int width;
        public int Width
        {
            get { return width; }
        }

        private int height;
        public int Height
        {
            get { return height; }
        }
	
	
	
	
	
    }
}
